﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>呷饭网</title>
    <link rel="stylesheet" type="text/css" href="./styles/mobile.css" />
    <link href="styles/jquery.ui.all.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.bgiframe-2.1.1.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.core.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.mouse.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.button.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.draggable.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.position.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.dialog.js"></script>
    <link href="styles/flexy-menu.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/flexy-menu.js"></script>
    <script type="text/javascript" src="scripts/common.js"></script>

    <style type="text/css">
        .validateTips
        {
            border: 0px solid transparent;
            padding: 0.3em;
        }
    </style>

    <script type="text/javascript">
        var OrderId;
        var PageFlag;
        var array = new Array();
        var count = 0;

        $(function () {
            OrderId = getParameter("OrderId");
            PageFlag = getParameter("PageFlag");
            getUserInfo();
            getListData(OrderId);

            $(".flexy-menu").flexymenu({ speed: 100 });
            $('.goback').click(function () {
                if (PageFlag == "1") {
                    window.location.href = "./manager.html";
                }
                else if (PageFlag == "2") {
                    window.location.href = "./clean.html";
                }
                else if (PageFlag == "3") {
                    window.location.href = "./cashier.html";
                }
            });

            $("#dialog").dialog("destroy");
            $("#UpdateNum").dialog("destroy");
            $("#UpdateNum").dialog({
                autoOpen: false,
                resizable: false,
                width: '95%',
                height: 210,
                modal: true,
                position: ["center", "center"],
                buttons: {
                    "关 闭": function () {
                        $(this).dialog("close");
                    },
                    "确 定": function () {
                        UpdateNum();
                    }
                }
            });
            $("#addCookbook").dialog("destroy");
            $("#addCookbook").dialog({
                autoOpen: false,
                resizable: false,
                width: '95%',
                height: 400,
                modal: true,
                position: ["center", "center"],
                buttons: {
                    "关 闭": function () {
                        $(this).dialog("close");
                    },
                    "确 定": function () {
                        updateOrderCookBook();
                    }
                }
            });

            $("#delCookbook").dialog("destroy");
            $("#delCookbook").dialog({
                autoOpen: false,
                resizable: false,
                width: 270,
                height: 140,
                modal: true,
                position: ["center", "center"],
                buttons: {
                    "关 闭": function () {
                        $(this).dialog("close");
                    },
                    "确 定": function () {
                        cancelCookbook();
                    }
                }
            });
        });

        function getListData(OrderId) {
            getOrderDetails(OrderId);
        }

        //获取已就坐订单和订单菜单信息
        function getOrderDetails(OrderId) {
            $("#tbllist").html("");
            var datas = "&OrderId=" + OrderId;
            var url = "CommonPage.aspx?opration=getOrderDetails" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        $("#query-tips")[0].style.display = "none";
                        $("#jsxf-tips")[0].style.display = "none";
                        $("#hide_H_Id").val(data.H_Id);
                        $("#hide_U_Id").val(data.U_Id);
                      
                        $("#ContactUser").text(data.ContactUser);
                        $("#Dinecondition").text(data.DineName + "(" + data.PeopleNum + "人桌)");
                        var ContactMobile = "";
                        if (data.ContactMobile == "") {
                            ContactMobile = "无";
                        }
                        else {
                            ContactMobile = data.ContactMobile;
                        }
                        $("#ContactMobile").text(ContactMobile);
                        $("#hide_DineTable").val(data.DineTable);
                        $("#LastModifyDate").text(data.LastModifyDate);
                        if (data.TableState == "0") {
                            $("#showDineTable")[0].style.display = "none";
                        }
                        else {
                            $("#showDineTable")[0].style.display = "";
                        }
                        $("#Prices").text(data.Prices);
                        
                        if (data.Numbers == "0") {
                            $("#query-tips")[0].style.display = "";
                            $("#querytips").text(data.Msg);
                            $("#jsxf-tips")[0].style.display = "";
                            $("#jsxftips").text("没有查询到即时消费信息！");
                        }
                        else {
                            count = 0;
                            for (var i = 0; i < data.List.length; i++) {
                                if (data.List[i].DishState != "1") {
                                    count++;
                                }
                            }

                            if (count > 0) {
                                $("#td_setCookbook")[0].style.display = "none";
                                if (data.U_Id == "-1") {
                                    $("#td_setBindUser")[0].style.display = "";
                                }
                                else {
                                    $("#td_setBindUser")[0].style.display = "none";
                                }
                            }
                            else {
                                $("#td_setCookbook")[0].style.display = "";
                            }

                            var cdNum = 0;
                            var jsxfNum = 0;
                            var stateFlag = 0;
                            for (var i = 0, str = '', jsxf = ''; i < data.List.length; i++) {
                                if (data.List[i].IsDisplay == "0") {
                                    cdNum++;
                                    if (count > 0) {
                                        if (data.List[i].Unit == "斤") {
                                            if (data.List[i].Weight == "0.00") {
                                                str += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='r'><a href='javascript:;' onclick=\"addNums('" + data.List[i].DishId + "','" + data.List[i].Price + "')\" style='font-size:13px;'>分量</a></td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'><a href='#' onclick=\"showCookbook('" + data.List[i].DishName + "','" + data.List[i].Num + "','" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].IsDisplay + "');\">取消</a></td><td class='r'></td></tr>";
                                            }
                                            else {
                                                if (data.List[i].DishState == "4") {
                                                    stateFlag++;
                                                    str += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'></td><td class='r'></td></tr>";
                                                }
                                                else if (data.List[i].DishState == "2" || data.List[i].DishState == "3") {
                                                    stateFlag++;
                                                    str += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'><a href='#' onclick=\"updateCookWeight('" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].DishState + "');\">催</a></td><td class='r'></td></tr>";
                                                }
                                                else {
                                                    str += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'><a href='#' onclick=\"updateCookWeight('" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].DishState + "');\">催</a></td><td class='r'><a href='#' onclick=\"showCookbook('" + data.List[i].DishName + "','" + data.List[i].Num + "','" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].IsDisplay + "');\">取消</a></td></tr>";
                                                }
                                            }
                                        }
                                        else {
                                            if (data.List[i].DishState == "4") {
                                                stateFlag++;
                                                str += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'></td><td class='r'></td></tr>";
                                            }
                                            else if (data.List[i].DishState == "2" || data.List[i].DishState == "3") {
                                                stateFlag++;
                                                //str += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'><a href='#' onclick=\"updateCookWeight('" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].DishState + "');\">催</a></td><td class='r'></td></tr>";
                                                str += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'><a href='#' onclick=\"updateCookWeight('" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].DishState + "');\">催</a></td><td class='r'><a href='#' onclick=\"showCookbook('" + data.List[i].DishName + "','" + data.List[i].Num + "','" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].IsDisplay + "');\">取消</a></td></tr>";
                                            }
                                            else {
                                                str += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'><a href='#' onclick=\"updateCookWeight('" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].DishState + "');\">催</a></td><td class='r'><a href='#' onclick=\"showCookbook('" + data.List[i].DishName + "','" + data.List[i].Num + "','" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].IsDisplay + "');\">取消</a></td></tr>";
                                            }
                                        }
                                    }
                                    else {
                                        str += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'><a href='#' onclick=\"showCookbook('" + data.List[i].DishName + "','" + data.List[i].Num + "','" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].IsDisplay + "');\">取消</a></td><td class='r'></td></tr>";
                                    }
                                }
                                else {
                                    jsxfNum++;
                                    if (count > 0) {
                                        if (data.List[i].DishState == "10" || data.List[i].DishState == "4") {
                                            jsxf += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'></td><td class='r'></td></tr>";
                                        }
                                        else {
                                            jsxf += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'><a href='#' onclick=\"updateCookWeight('" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].DishState + "');\">催</a></td><td class='r'><a href='#' onclick=\"showCookbook('" + data.List[i].DishName + "','" + data.List[i].Num + "','" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].IsDisplay + "');\">取消</a></td></tr>";
                                        }
                                    }
                                    else {
                                        jsxf += "<tr><td class='l' style='width:30%;'>" + data.List[i].DishName + "<b>" + data.List[i].Copies + "</b></td><td class='c'>￥" + data.List[i].Price + "</td><td class='cc'>" + data.List[i].StateName + "</td><td class='r'><a href='#' onclick=\"showCookbook('" + data.List[i].DishName + "','" + data.List[i].Num + "','" + data.Id + "','" + data.List[i].DishId + "','" + data.List[i].IsDisplay + "');\">取消</a></td><td class='r'></td></tr>";
                                    }
                                }
                            }
                            $("#cdNum").text(cdNum);
                            $("#jsxfNum").text(jsxfNum);
                            $("#tbllist").html(str);
                            if (jsxfNum == 0) {
                                $("#jsxf-tips")[0].style.display = "";
                                $("#jsxftips").text("没有查询到即时消费信息！");
                            }
                            else {
                                $("#jsxfList").html(jsxf);
                            }
                            if (stateFlag == 0) {
                                $("#tbCancel")[0].style.display = "";
                            }
                            else {
                                $("#tbCancel")[0].style.display = "none";
                            }
                        }
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            $("#query-tips")[0].style.display = "";
                            $("#querytips").text(data.Msg);
                            $("#jsxf-tips")[0].style.display = "";
                            $("#jsxftips").text("没有查询到即时消费信息！");
                        }
                    }
                }
            });
        }

        //催菜
        function updateCookWeight(OrderId, DishId, DishState) {
            var datas = "&OrderId=" + OrderId + "&DishId=" + DishId + "&DishState=" + DishState;
            var url = "CommonPage.aspx?opration=updateCookWeight" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        updateTip(data.Msg, true, "Method", OrderId);
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            updateTip(data.Msg, false, "", "");
                        }
                    }
                }
            });
        }

        //取消菜品
        function showCookbook(DishName, Num, OrderId, DishId, IsDisplay) {
            var datas = "&OrderId=" + OrderId + "&DishId=" + DishId + "&Num=" + $("#iptNum").val() + "&IsDisplay=" + IsDisplay;
            var url = "CommonPage.aspx?opration=cancelCookbook" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        //updateTip(data.Msg, true, "Method", $("#hide_OrderId").val());
                        getListData(OrderId);
                    }
                    else {
                        updateTip(data.Msg, false, "", "");
                    }
                }
            });
        }

        function showCookbooks(DishName, Num, OrderId, DishId, DishState) {
            $("#DishName").text(DishName);
            $("#iptNum").val(Num);
            $("#hide_OrderId").val(OrderId);
            $("#hide_DetailId").val(DishId);
            $("#hide_DishState").val(DishState);
            $("#delCookbook").dialog('open');
        }
        function cancelCookbook() {
            var datas = "&OrderId=" + $("#hide_OrderId").val() + "&DishId=" + $("#hide_DetailId").val() + "&Num=" + $("#iptNum").val() + "&DishState=" + $("#hide_DishState").val();
            var url = "CommonPage.aspx?opration=cancelCookbook" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        $("#delCookbook").dialog("close");
                        //updateTip(data.Msg, true, "Method", $("#hide_OrderId").val());
                        getListData($("#hide_OrderId").val());
                    }
                    else {
                        updateTip(data.Msg, false, "", "");
                    }
                }
            });
        }

        //减少菜品份数
        function subtractNums() {
            if (parseInt($("#iptNum").val()) != 0) {
                $("#iptNum").val(parseInt($("#iptNum").val()) - 1);
            }
        }

        //加菜
        function addCookbook() {
            $("input:text").each(function (a, b) {
                b.value = "0";
            });
            array = new Array();
            $("#addCookbook").dialog('open');
            getCookbookCategory();
            getCookbookList("ck_all", "");
        }

        //获取菜谱类别
        function getCookbookCategory() {
            $("#tblCookbook").html("");
            var url = "CommonPage.aspx?opration=getCookbookCategory";
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        var str = "<tr>";
                        str += "<td id='ck_all' style='padding-left:0;padding-right:0;'><a href=\"#\" onclick=\"getCookbookList('ck_all','');\">全部</a></td>";
                        for (var i = 0; i < data.List.length; i++) {
                            str += "<td id='ck_" + data.List[i].Id + "' style='padding-left:0;padding-right:0;'><a href=\"#\" onclick=\"getCookbookList('ck_" + data.List[i].Id + "','" + data.List[i].Id + "');\">" + data.List[i].Name + "</a></td>";
                        }
                        str += "</tr>";
                        $("#tblCookbook").html(str);
                        getCookbookList("ck_all", "");
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            updateTip(data.Msg, false, "", "");
                        }
                    }
                }
            });
        }

        //获取菜谱菜单
        function getCookbookList(id, flag) {
            $("#tblCookbook tr").find("td").each(function (a, b) {
                $("#" + b.id).removeClass("active");
                if (b.id == id) {
                    $("#" + id).addClass("active");
                }
            });

            $("input:text").each(function (a, b) {
                if (array.length != 0) {
                    for (var j = 0; j < array.length; j++) {
                        if (b.id == array[j].split(',')[0] && parseInt(b.value) != 0) {
                            array.splice(j, 1);
                        }
                    }
                }
                var str = b.id + "," + b.value;
                if (parseInt(b.value) != 0) {
                    array.push(str);
                }
            });

            $("#tblCookList").html("");
            var datas = "&flag=" + flag;
            var url = "CommonPage.aspx?opration=getCookbookList" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        $("#tips")[0].style.display = "none";
                        for (var i = 0, str = ''; i < data.List.length; i++) {

                            var EstimateClear = data.List[i].EstimateClear;
                            var tempstr = "";
                            if (EstimateClear == "-1") {
                                //tempstr = "<span>有<span>";
                            }
                            else if (EstimateClear == "0") {
                                tempstr = "<span>无<span>";
                            } else {
                                tempstr = "<span>剩余：" + EstimateClear + "份<span>";
                            } 
                            str += "<tr><td class='l' style='padding-left:0;padding-right:0;width:100px;'>" + data.List[i].Name + "</td><td class='l' style='padding-left:0;padding-right:0;text-align:right;'>" + data.List[i].Price + "</td><td class='c' style='padding-left:0;padding-right:0;vertical-align:middle;text-align:center;'><img src='images/jian.png' onclick='subtractNum(" + data.List[i].CategoryId + "," + data.List[i].Id + "," + data.List[i].IsDisplay + ");'/><input type='text' id='ipt_" + data.List[i].CategoryId + "_" + data.List[i].Id + "_" + data.List[i].IsDisplay + "' readonly='readonly' value='0' style='width:20px;vertical-align:top;text-align:center;'/><img src='images/jia.png' onclick='addNum(" + data.List[i].CategoryId + "," + data.List[i].Id + "," + data.List[i].IsDisplay + "," + data.List[i].EstimateClear + ");'/> " + tempstr + " </td><td class='r' style='padding-left:0;padding-right:0;text-align:right;'><a href='#' onclick='deleteCookbook(" + data.List[i].CategoryId + "," + data.List[i].Id + "," + data.List[i].IsDisplay + ");'>删除</a></td></tr>";
                        }
                        $("#tblCookList").html(str);

                        if (array.length != 0) {
                            for (var j = 0; j < array.length; j++) {
                                $("input:text").each(function (a, b) {
                                    if (array[j].split(',')[0] == b.id) {
                                        b.value = array[j].split(',')[1];
                                    }
                                });
                            }
                        }
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            $("#tips")[0].style.display = "";
                            $("#msgtip").text(data.Msg);
                        }
                    }
                }
            });
        }

        //提交菜单
        function updateOrderCookBook() {
            $("input:text").each(function (a, b) {
                if (array.length != 0) {
                    for (var j = 0; j < array.length; j++) {
                        if (b.id == array[j].split(',')[0] && parseInt(b.value) != 0) {
                            array.splice(j, 1);
                        }
                    }
                }
                var str = b.id + "," + b.value;
                if (parseInt(b.value) != 0) {
                    array.push(str);
                }
            });

            if (array.length == 0) {
                updateTip("请先点菜，再确定！", false, "", "");
            }
            else {
                var StateFlag;
                if (count > 0) {
                    StateFlag = 10;
                }
                else {
                    StateFlag = 1;
                }
                array = array.join('|');
                var datas = "&OrderId=" + OrderId + "&array=" + array + "&U_Id=" + $("#hide_U_Id").val() + "&StateFlag=" + StateFlag;
                var url = "CommonPage.aspx?opration=updateOrderCookBook" + datas;
                $.ajax({
                    url: url,
                    type: "post",
                    dataType: 'json',
                    success: function (data) {
                        if (data.Success) {
                            $("#addCookbook").dialog("close");
                            //updateTip(data.Msg, true, "Method", OrderId);
                            getListData(OrderId);
                        }
                        else {
                            updateTip(data.Msg, false, "", "");
                        }
                    }
                });
            }
        }

        function addNums(Id, Price) {
            $("#hide_DetailIdnow").val(Id);
            $("#pricenow").val(Price);
            $("#UpdateNum").dialog('open');
        }

        function checkRegexp(o, regexp, n) {
            if (!(regexp.test(o.val()))) {
                o.addClass('ui-state-error');
                updateTip(n, false, "", "");
                return false;
            } else {
                return true;
            }
        }

        function UpdateNum() {
            var DetailId = $("#hide_DetailIdnow"),//菜品烹调ID
                pricenow = $("#pricenow"),//时价(默认为初始价格,可修改.)
                Num = $("#numnow"),//重量

            allFields = $([]).add(DetailId).add(pricenow).add(Num);
            var bValid = true;
            allFields.removeClass('ui-state-error');

            bValid = bValid && checkRegexp(pricenow, /.+/, "请输入时价金额！");
            bValid = bValid && checkRegexp(pricenow, /^[-\+]?\d+(\.\d+)?$/, "请输入正确的时价金额！");
            if (parseFloat(pricenow.val()) <= 0) {
                updateTip("时价金额不能小于或等于零！", false, "", "");
                return;
            }

            bValid = bValid && checkRegexp(Num, /.+/, "请输入重量！");
            bValid = bValid && checkRegexp(Num, /^[-\+]?\d+(\.\d+)?$/, "请输入正确的重量！");
            if (parseFloat(Num.val()) <= 0) {
                updateTip("重量不能小于或等于零！", false, "", "");
                return;
            }

            if (bValid) {
                var datas = "&DetailId=" + DetailId.val() + "&Price=" + pricenow.val() + "&Num=" + Num.val();
                var url = "CommonPage.aspx?opration=UpdateNum" + datas;
                $.ajax({
                    url: url,
                    type: "post",
                    dataType: 'json',
                    success: function (data) {
                        if (data.Success) {
                            $("#UpdateNum").dialog("close");
                            getListData(OrderId);
                        }
                        else {
                            updateTip(data.Msg, false, "", "");
                        }
                    }
                });
            }
        }

        //订单菜品确认
        function setCookbook() {
            var datas = "&OrderId=" + OrderId;
            var url = "CommonPage.aspx?opration=setCookbook" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        getListData(OrderId);
                    }
                    else {
                        updateTip(data.Msg, false, "", "");
                    }
                }
            });
        }

        //绑定注册用户
        function setBindUser() {
            $("#bindUser").dialog("destroy");
            $("#bindUser").dialog({
                autoOpen: true,
                resizable: false,
                width: 270,
                height: 140,
                modal: true,
                position: ["center", "center"],
                buttons: {
                    "关 闭": function () {
                        $(this).dialog("close");
                    },
                    "确 定": function () {
                        var Mobile = $("#txtMobile"),
                        allFields = $([]).add(Mobile);
                        var bValid = true;
                        allFields.removeClass('ui-state-error');

                        bValid = bValid && checkRegexp(Mobile, /.+/, "请输入手机号码！");
                        bValid = bValid && checkRegexp(Mobile, /^(\d{2,3}-)?1[3|5|8]\d{9}?$/, "请输入正确的手机号码！");

                        if (bValid) {
                            var datas = "&OrderId=" + OrderId + "&Mobile=" + Mobile.val();
                            var url = "CommonPage.aspx?opration=setBindUser" + datas;
                            $.ajax({
                                url: url,
                                type: "post",
                                dataType: 'json',
                                success: function (data) {
                                    $("#bindUser").dialog("close");
                                    if (data.Success) {
                                        getListData(OrderId);
                                    }
                                    else {
                                        updateTip(data.Msg, false, "", "");
                                    }
                                }
                            });
                        }
                    }
                }
            });
        }

        //取消订单
        function cancelDineTable() {
            $(".dialogTip").text("是否取消订单？")
            $("#dialog").dialog({
                resizable: false,
                height: 120,
                modal: true,
                position: ["center", "center"],
                buttons: {
                    "关 闭": function () {
                        $(this).dialog("close");
                    },
                    "确 定": function () {
                        var datas = "&HotelId=" + $("#hide_H_Id").val() + "&OrderId=" + OrderId;
                        var url = "CommonPage.aspx?opration=cancelDineTable" + datas;
                        $.ajax({
                            url: url,
                            type: "post",
                            dataType: 'json',
                            success: function (data) {
                                $(this).dialog("close");
                                if (data.Success) {
                                    //updateTip(data.Msg, true, "URL", data.Url);
                                    document.location.href = data.Url;
                                }
                                else {
                                    updateTip(data.Msg, false, "", "");
                                }
                            }
                        });
                    }
                }
            });
        }
    </script>
</head>

<body>
    <div class="wrapall">
        <table class="topbar">
            <tr>
                <td class="l"><a class="goback">返回</a></td>
                <td class="c" id="H_Name"></td>
                <td class="r" align="right">
                    <ul class="flexy-menu">
                        <li id="lilist">
                        </li>
                    </ul>
                </td>
            </tr>
        </table>
        <p class="textinfo"><b id="ContactUser"></b>已就坐</p>
        <table class="tblhd">
            <tr>
                <td class="l" id="Dinecondition"></td>
                <td class="c"></td>
                <td style="width:30%;">
                    <table style="width:100%; display:none;" id="tbCancel">
                        <tr>
                            <td align="right" style="text-align:center;border-top:0px solid #09F; background-color:#09F;font-family:'微软雅黑', '黑体';font-size:13px;padding:8px 10px;"><a href="#" onclick="cancelDineTable();" style="color:white;">取消订单</a></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <table class="tblbd">
            <tr>
                <th>电话</th>
                <td id="ContactMobile"></td>
                <td class="r">金额共<b id="Prices" style="color:red;">0</b>元</td>
            </tr>
            <tr>
                <th>就坐时间</th>
                <td id="LastModifyDate"></td>
                <td></td>
            </tr>
        </table>
        <table class="tblbtn">
            <tr>
                <td id="showDineTable" style="display:none;padding:5px 8px;"><a href="#" onclick="showDineTable();">换桌</a></td>
                <td style="padding:5px 8px;"><a href="#" onclick="addCookbook();">加菜</a></td>
                <td id="td_setCookbook" style="display:none;padding:5px 8px;"><a href="#" onclick="setCookbook();">确认</a></td>
                <td id="td_setBindUser" style="display:none;padding:5px 8px;"><a href="#" onclick="setBindUser();">绑定</a></td>
            </tr>
        </table>
        <table class="tblhd">
            <tr>
                <td class="l">菜单</td>
                <td class="c"></td>
                <td class="r">（共<b id="cdNum">0</b>份）</td>
            </tr>
        </table>
        <table class="tbllist" id="tbllist">
        </table>
        <span class="tips" id="query-tips" style="display: none;"><i></i><b id="querytips"></b>
            
        </span>
        <br />
        <table class="tblhd">
            <tr>
                <td class="l">即时消费</td>
                <td class="c"></td>
                <td class="r">（共<b id="jsxfNum">0</b>份）</td>
            </tr>
        </table>
        <table class="tbllist" id="jsxfList">
        </table>
        <span class="tips" id="jsxf-tips" style="display: none;"><i></i><b id="jsxftips"></b>
            
        </span>
        <br />
    </div>
    <div id="dialog" title="提示信息" style="text-align:center; margin:auto; vertical-align: middle;">
        <p class="dialogTip"></p>
    </div>
    <div id="DineTable" title="可换桌位" style="margin:auto;">
        <table class="tbllist" id="tblDineTable">
        </table>
    </div>
    <div id="UpdateNum" title="修改分量" style="margin:auto;">
        <table class="tbllist" id="Table1">
        <tr><td>时价：</td><td><input type="text" id="pricenow" readonly="readonly" />
                           <input type="hidden" id="hide_DetailIdnow" value="" />  
        </td></tr>
        <tr><td>重量：</td><td><input type="text" id="numnow" /></td></tr>
        </table>
    </div>
    <div id="addCookbook" title="加菜列表" style="margin:auto;">
        <table class="tab1" id="tblCookbook">
        </table>
        <table class="tbllist" id="tblCookList">
        </table>
        <span class="tips" id="tips" style="display:none;"><i></i><b id="msgtip"></b>
        </span>
        <br />
    </div>
    <div id="delCookbook" title="取消菜品">
        <table style="border:0px;">
            <tr>
                <br />
                <td id="DishName" style="vertical-align:bottom;width:70%;">菜单菜品</td>
                <td align="left"><input type="text" id="iptNum" readonly="readonly" value="0" style="width:40px;vertical-align:top;"/><img src="images/jian.png" onclick="subtractNums();"/></td>
            </tr>
        </table>
    </div>
    <div id="bindUser" title="绑定注册账号" style="display:none;">
        <table style="border:0px;">
            <tr>
                <br />
                <td style="vertical-align:bottom;width:50%;">手机号码</td>
                <td align="left"><input type="text" id="txtMobile" maxlength="11" /></td>
            </tr>
        </table>
    </div>
    <input type="hidden" id="hide_DineTable" value="" />
    <input type="hidden" id="hide_OrderId" value="" />
    <input type="hidden" id="hide_DetailId" value="" />
    <input type="hidden" id="hide_H_Id" value="" />
    <input type="hidden" id="hide_U_Id" value="" />
    <input type="hidden" id="hide_DishState" value="" />
</body>
</html>
